import { request } from "@/http/axios"
import type { 
  OverallStatsData,
  ShopCategoryStatsData,
  UserGrowthData,
  OrderStatsData,
  GetStatsRequestData,
  StatisticsResponseData,
  RealTimeStatsData
} from "./type"

/** 获取总体统计数据 */
export function getOverallStatsApi() {
  return request<OverallStatsData>({
    url: "statistics/overall",
    method: "get"
  })
}

/** 获取商户类型分布统计 */
export function getShopCategoryStatsApi() {
  return request<ShopCategoryStatsData[]>({
    url: "statistics/shop-categories",
    method: "get"
  })
}

/** 获取用户增长统计 */
export function getUserGrowthStatsApi(params?: GetStatsRequestData) {
  return request<UserGrowthData[]>({
    url: "statistics/user-growth",
    method: "get",
    params
  })
}

/** 获取订单统计 */
export function getOrderStatsApi(params?: GetStatsRequestData) {
  return request<OrderStatsData[]>({
    url: "statistics/orders",
    method: "get",
    params
  })
}

/** 获取完整统计数据 */
export function getStatisticsApi(params?: GetStatsRequestData) {
  return request<StatisticsResponseData>({
    url: "statistics",
    method: "get",
    params
  })
}

/** 获取实时统计数据 */
export function getRealTimeStatsApi() {
  return request<RealTimeStatsData>({
    url: "statistics/realtime",
    method: "get"
  })
}

/** 导出统计报告 */
export function exportStatsReportApi(params?: GetStatsRequestData & { format?: 'excel' | 'pdf' | 'csv' }) {
  return request<Blob>({
    url: "statistics/export",
    method: "get",
    params,
    responseType: 'blob'
  })
}